<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}




$id=empty($_GET['id'])?0:(int)$_GET['id'];
if(empty($id)){

    error_html("没有找到加工单！","","");
}else{
    $workinfo=$ezhand->select("workman",'*','id="'.$id.'"');
    if(empty($workinfo["orderid"])){
        error_html("没有找到加工单！","","");
    }
    $codenumb=$workinfo["code_numb"];
    $ordernum=$workinfo["ordernum"];
    $work_items=$ezhand->select_all("workman_items",'*','wid="'.$id.'"');
    
    $goodsnum=$workinfo["subitems"];
    $metnum=$workinfo["metnums"];
    
    $where="o.id=og.orderid and o.id in (".$workinfo["orderid"].") and o.status in (1,2)  ";
    
    $ordergoods=$ezhand->select_all("shopping3_order o,shopping3_order_goods og",'og.goodsid,sum(og.total) as total',''.$where.'  group by og.goodsid ');

    $ordergoodstemp=$ordergoods;
    
    $goodslisttemp=$ezhand->select_all("shopping3_goods","*","1");
    while(list($k,$v)=each($goodslisttemp)){
        $gid=$v["id"];
        $goodslist[$gid]=$v;    
        
    }
    
    
    /*
            //取得食材明细
        $materiallisttemp=$ezhand->select_all("material","*","1");
        while(list($k,$v)=each($materiallisttemp)){
            $pid1=$v["id"];
            $materiallist[$pid1]=$v;    
            
        }
        
        //取得菜品对应食材的明细
        $goodsmetlist=array();
        
        $metnamelist=array();
        $metlist=$ezhand->select_all("goods_items","*","1 group by tid,mid");
        while(list($k,$v)=each($metlist)){
         $tid=$v["tid"];
        
         $mid=$v["mid"];
        
         $goodsmetlist[$tid][]=$v;
         $metnamelist[$mid]=$v["mname"]; 
        }
        
        */
        
        $donelist=array();
        $donelisttemp=$ezhand->select_all("workman_done","*","workmanid=".$id);
        while(list($k,$v)=each($donelisttemp)){
            $gid=$v["goodsid"];
            $donelist[$gid]=$v;
        }        
        $blnum=$ezhand->count("workman","parentid=".$id);  
        $bllistrow= $ezhand->select_all("workman","*","parentid=".$id);        
        //if($workinfo["zjstatus"]==2 or $workinfo["zjstatus"]==3){
           $checklist=$ezhand->select_all("workman_checklist","*","workmanid=".$id." order by goodsid asc,id asc");
        //}
       // if(!empty($checklist)){
         //   $workinfo["zjstatus"]=3;
        //}
        
}

$token=md5(EZKEY.$codenumb.$_SESSION['EZ_Admin']['id']);
?>